import request from '@/utils/request';
import { xlsxHost } from '@/utils/utils';
function paramsStringHandler(params: any) {
  var paramsString = '?'
  for (var k in params) {
    paramsString += `${k}=${params[k]}&`
  }
  return paramsString.substr(0,paramsString.length-1)
}

export async function queryRule(params?: any) {
  return request('/app-admin/activity/pass/listActivityUserPassDataByPage', {
    params,
  });
}
// export async function selectStudent(params?: { key?:string}) {
//   return request('/app-admin/outsourcing/activity/searchUser', {
//     params: {
//       ...params,
//       group:1
//     }
//   });
// }
// select2相关接口
// 查学生(昵称 + 手机号)
export async function selectStudent(params: {
  phone?:string,
  activityId:number
}) {
  return request('/app-admin/activity/pass/listStuFuzzy', {
    params
  });
}

export async function selectClass(params: {
  name?:string,
  activityId:number
}) {
  return request('/app-admin/activity/pass/listGroupFuzzy', {
    params
  });
}

export async function selectTeacher(params: {
  param?:string,
  activityId:number
}) {
  return request('/app-admin/activity/pass/listTeaFuzzy', {
    params
  });
}

export async function selectTask(params: {
  activityId:number
}) {
  return request('/app-admin/activity/pass/listPassByActivityId', {
    params
  });
}


export async function queryInfo(params?: any) {
  return request('/app-admin/outsourcing/activity/info', {
    params,
  });
}
export async function selectActivity(params?: { key?:string}) {
  return request('/app-admin/outsourcing/activity/select', {
    params: {
      ...params,
      group:1
    }
  });
}
export async function taskExport(params: {
  activityId: string;
  uid:string
} ) {
  return Promise.resolve(xlsxHost+'/app-admin/outsourcing/activityTask/export'+paramsStringHandler(params))
}


export async function initFileUploadTask(params?: any) {
  return request('/app-admin/activity/pass/exportActivityUserPassData', {
    params,
  });
}

